<?php if (!defined('THINK_PATH')) exit();?><!-- widget grid -->
<section id="widget-grid" class="">

	<!-- row -->
	<div class="row">
            
		<!-- NEW WIDGET START -->
		<article class="col-sm-12 col-md-12 col-lg-12">

			<!-- Widget ID (each widget will need unique ID)-->
			<div class="jarviswidget jarviswidget-color-greenDark" data-widget-deletebutton="false" id="wid-id-2" data-widget-editbutton="false">
				<!-- widget options:
				usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

				data-widget-colorbutton="false"
				data-widget-editbutton="false"
				data-widget-togglebutton="false"
				data-widget-deletebutton="false"
				data-widget-fullscreenbutton="false"
				data-widget-custombutton="false"
				data-widget-collapsed="true"
				data-widget-sortable="false"

				-->
				<header>
					<span class="widget-icon"> <i class="fa fa-table"></i> </span>
					<h2>考试安排</h2>

				</header>

				<!-- widget div-->
				<div>

					<!-- widget edit box -->
					<div class="jarviswidget-editbox">
						<!-- This area used as dropdown edit box -->

					</div>
					<!-- end widget edit box -->

					<!-- widget content -->
					<div class="widget-body no-padding">					
						
						<table class="table table-hover">
							<thead>
								<tr>
                                                                    <th>编号</th>
                                                                    <th>考试名</th>
                                                                    <th>报名时间</th>
                                                                    <th>考试时间</th>
                                                                    <th>考试类型</th>
                                                                    <th>报名情况(已报/总数)</th>
                                                                    <th>操作</th>
								</tr>
							</thead>
							<tbody>
                                                            <?php if(is_array($exams)): $i = 0; $__LIST__ = $exams;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><tr>
									<td><?php echo ($v["id"]); ?></td>
									<td><?php echo ($v["name"]); ?></td>
									<td><?php echo (date('Y/m/d H:i',$v["start_time"])); ?> 到 <?php echo (date('Y/m/d H:i',$v["end_time"])); ?></td>
									<td><?php echo (date('Y-m-d H:i',$v["time"])); ?></td>
                                                                        <td>
                                                                            <?php switch($v["type"]): case "1": ?>免费报名<?php break; case "2": ?>收费报名【<?php echo ($v["pay_num"]); ?>元】<?php break; endswitch;?>
                                                                        </td>
                                                                        <td>/<?php echo ($v["people_num"]); ?></td>
                                                                        <td>
                                                                            <a class="btn btn-primary" href="#<?php echo U('Exam/editExam',array('id'=>$v['id']));?>">编辑</a> 
                                                                            <a class="btn btn-danger delexam" data-id="<?php echo ($v["id"]); ?>" href="javascript:void(0)">删除</a></td>
								</tr><?php endforeach; endif; else: echo "" ;endif; ?>
							</tbody>
						</table>

					</div>
					<!-- end widget content -->

				</div>
				<!-- end widget div -->

			</div>
			<!-- end widget -->

		</article>
		<!-- WIDGET END -->
                
        </div>
        
</section>

<script type="text/javascript">
	// DO NOT REMOVE : GLOBAL FUNCTIONS!
	pageSetUp();

	// PAGE RELATED SCRIPTS
        $('.delexam').on('click', function(e){
            var $this = $(this);
            var id = $this.attr('data-id');
            $.SmartMessageBox({
                    title : "删除",
                    content : "建议：若此项考试未开始或已经结束可以删除，若已经进行的考试建议保留",
                    buttons : '[No][Yes]'
            }, function(ButtonPressed) {
                    if (ButtonPressed === "Yes") {
                        
                        $.post('<?php echo U("Exam/delExam");?>',{id:id},function(data,status){
                            if(data.status == 1){
                                $this.parents('tr').remove();
                            }
                            $.smallBox({
                                    title : "操作提示",
                                    content : data.info,
                                    color : "#a90329",
                                    iconSmall : "fa fa-check fa-2x fadeInRight animated",
                                    timeout : 4000
                            });
                        });
                    }
                    if (ButtonPressed === "No") {
                           
                    }

            });

        })
</script>